let timeoutId

function startTimeout(cb, delay) {
  if (typeof cb !== 'function') {
    throw new Error('callback 需为函数')
  }
  clearTimeout(timeoutId)
  if (delay) {
    timeoutId = setTimeout(cb, delay)
  } else {
    cb()
  }
}
function stopTimeout() {
  clearTimeout(timeoutId)
}

export { startTimeout, stopTimeout }
